import { InputNumber } from 'antd';
export default class MenuItem extends React.Component {
    onClick = () => {
        const { onClick, dataKey } = this.props;
        if (onClick) {
            onClick(dataKey)
        }
    }
    changeNumber = (v) => {
        const { onChangeNumber, dataKey } = this.props;
        if (onChangeNumber) {
            onChangeNumber(dataKey, v)
        }
    }
    shouldComponentUpdate(nextProps, nextState) {
        return nextProps.icon !== this.props.icon ||
            nextProps.title !== this.props.title ||
            nextProps.number !== this.props.number ||
            nextProps.showNumber !== this.props.showNumber ||
            nextProps.dataKey !== this.props.dataKey
    }
    render() {
        const { icon, title, number = 1, onClickNumber,showNumber } = this.props;
        return (
            <li onClick={this.onClick}>
                <span className="icon"><i className={icon}></i></span>
                <span className="title">
                    {title}
                </span>
               {showNumber && <div className="number" onClick={onClickNumber} >
                    <InputNumber ecId={`${this && this.props && this.props.ecId || ''}_InputNumber@66e057`} value={number} min={1} onChange={this.changeNumber} />
                </div>}
            </li>
        )
    }
}